<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>编辑便签 - 便签系统</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/font/bootstrap-icons.css" rel="stylesheet">
    <link href="/css/custom.css" rel="stylesheet">
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-dark">
        <div class="container">
            <a class="navbar-brand" href="/memo/list">
                <i class="bi bi-sticky me-2"></i>便签系统
            </a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav me-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="/memo/list">
                            <i class="bi bi-collection me-1"></i>我的便签
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/memo/add">
                            <i class="bi bi-plus-circle me-1"></i>添加便签
                        </a>
                    </li>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="categoriesDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                            <i class="bi bi-tag me-1"></i>分类管理
                        </a>
                        <ul class="dropdown-menu" aria-labelledby="categoriesDropdown">
                            <li><a class="dropdown-item" href="/category/list"><i class="bi bi-list-ul me-1"></i>查看分类</a></li>
                            <li><a class="dropdown-item" href="/category/add"><i class="bi bi-plus-lg me-1"></i>添加分类</a></li>
                        </ul>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/memo/recycle-bin">
                            <i class="bi bi-trash me-1"></i>回收站
                        </a>
                    </li>
                </ul>
                <ul class="navbar-nav">
                    <li class="nav-item">
                        <a class="nav-link" href="/logout">
                            <i class="bi bi-box-arrow-right me-1"></i>退出登录
                        </a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <div class="container mt-4">
        <div class="row mb-4">
            <div class="col">
                <h2>
                    <i class="bi bi-pencil-square me-2"></i>编辑便签
                </h2>
                <p class="text-muted">修改您的便签内容</p>
            </div>
        </div>
        
        <div class="card fade-in">
            <div class="card-body">
                <form action="/memo/edit" method="post" class="mt-2">
                    <input type="hidden" name="id" th:value="${memo.id}">
                    <div class="mb-4">
                        <label for="title" class="form-label">
                            <i class="bi bi-type-h1 me-1"></i>标题
                        </label>
                        <input type="text" class="form-control" id="title" name="title" th:value="${memo.title}" required>
                    </div>
                    <div class="mb-4">
                        <label for="categoryId" class="form-label">
                            <i class="bi bi-tag me-1"></i>分类
                        </label>
                        <select class="form-select" id="categoryId" name="categoryId">
                            <option value="">-- 无分类 --</option>
                            <option th:each="category : ${categories}" 
                                    th:value="${category.id}" 
                                    th:text="${category.name}"
                                    th:selected="${memo.category != null && memo.category.id == category.id}"
                                    th:style="'color: ' + ${category.color} + ';'">
                                分类名称
                            </option>
                        </select>
                        <div class="form-text">
                            <a href="/category/add" target="_blank">
                                <i class="bi bi-plus-circle me-1"></i>添加新分类
                            </a>
                        </div>
                    </div>
                    <div class="mb-4">
                        <label for="content" class="form-label">
                            <i class="bi bi-text-paragraph me-1"></i>内容
                        </label>
                        <textarea class="form-control" id="content" name="content" rows="12" th:text="${memo.content}"></textarea>
                    </div>
                    <div class="d-flex justify-content-between">
                        <a href="/memo/list" class="btn btn-secondary">
                            <i class="bi bi-arrow-left me-1"></i>返回
                        </a>
                        <button type="submit" class="btn btn-primary">
                            <i class="bi bi-save me-1"></i>保存
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html> 